<?php #sdsdsdsdsdsdd ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网盘首页</title>
    <style>
        .hide {
            display: none;
        }

        .c1 {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, .5);
            z-index: 2;
        }

        .c2 {
            background-color: white;
            position: fixed;
            width: 400px;
            height: 300px;
            top: 50%;
            left: 50%;
            z-index: 3;
            margin-top: -150px;
            margin-left: -200px;
        }

        #modal p {
            margin-left: 80px;
        }
    </style>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>

<body>
    <?php
    $currentFilePath = __FILE__;
    $dir = dirname($currentFilePath);

    session_start();

    if (!isset($_SESSION['user'])) {
        header("Location: login.html");
        die();
    }
    $user = $_SESSION['user'];
    $data = $dir . "\\file\\$user";


    ?>
    <h1 style="margin: auto;text-align:center">dms网盘</h1>
    <hr>
    <div>
        <span style="float: left;margin-left:30px">当前用户: &nbsp; <?php echo $user; ?></span>
        <span style="text-align: right;float:right;margin-right:30px"><input type="button" value="文件上传" onclick="Show();"></span>
    </div>
    <br>
    <br>
    <div id="shade" class="c1 hide"></div>
    <div id="modal" class="c2 hide">
        <form action="upload.php" method="post" enctype="multipart/form-data">
            <p>文件上传<input type="file" name="file" /></p>
            <br>
            <p>
                <input type="submit" value="上传">
                <input type="button" value="取消" onclick="Hide();">
            </p>
        </form>

    </div>
    <hr>
    <table class="table table-hover">
        <thead>
            <td>图标</td>
            <td>文件名</td>
            <td>管理</td>
        </thead>
        <?php
        $mulu = opendir($data);
        while ($wenjian = readdir($mulu)) {
            if ($wenjian != '.' and $wenjian != '..') {
                $img = "./file/$user/" . $wenjian;

                echo '<tr>';
                echo '<td><img height="150px" src="' . $img . '" alt="图标"></td>';
                echo '<td style="vertical-align: middle;text-align: center;">' . iconv('gbk', 'utf-8', $wenjian) . '</td>';
                echo '<td style="vertical-align: middle;text-align: center;"><a href="del_file.php?filename=' . $wenjian . '">删除&nbsp;&nbsp;</a><a href="download.php?filename=' . iconv('gbk', 'utf-8', $wenjian) . '">下载&nbsp;&nbsp;</a><a href="rename.php">重命名&nbsp;&nbsp;</a></td>';
                echo '</tr>';
            }
        }


        closedir($mulu);


        ?>
    </table>
    <hr>
    <script>
        function Show() {
            document.getElementById('shade').classList.remove('hide');
            document.getElementById('modal').classList.remove('hide');
        }

        function Hide() {
            document.getElementById('shade').classList.add('hide');
            document.getElementById('modal').classList.add('hide');
        }
    </script>
</body>

</html>
